package com.heima.wemedia.controller.v1;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDownUpDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 自媒体文章
 */
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;
    /**
     * 查询文章列表
     */
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findList(dto);
    }

    /**
     * 发布文章
     */
    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto){
        return wmNewsService.submit(dto);
    }

    /**
     * 修改回显文章
     */
    @GetMapping("/one/{id}")
    public ResponseResult<WmNews> findOne(@PathVariable("id") Integer id){
        return ResponseResult.okResult(wmNewsService.getById(id));
    }

    /**
     * 文章上下架
     */
    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDownUpDto dto){
        return wmNewsService.downOrUp(dto);
    }

    /**
     * 人工审核文章列表查询
     */
    @PostMapping("/list_vo")
    public ResponseResult list_vo(@RequestBody WmNewsAuthDto dto){
        return wmNewsService.list_vo(dto);
    }

    /**
     * 查询文章详情
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult one_vo(@PathVariable("id")  Integer id){
        return wmNewsService.one_vo(id);
    }

    /**
     * 审核失败
     */
    @PostMapping("/auth_fail")
    public ResponseResult auth_fail(@RequestBody WmNewsAuthDto dto){
        return wmNewsService.auth_fail(dto);
    }

    /**
     * 审核成功
     */
    @PostMapping("/auth_pass")
    public ResponseResult auth_pass(@RequestBody WmNewsAuthDto dto){
        return wmNewsService.auth_pass(dto);
    }

    /**
     *删除文章
     */
    @GetMapping("/del_news/{id}")
    public ResponseResult delNews(@PathVariable Long id){
       return wmNewsService.delNews(id);

    }
}
